﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _模拟Post请求
{
    class Program
    {
        static void Main(string[] args)
        {

            RequestData data = new RequestData();
            string StartTime = DateTime.Now.ToString("HH:mm:ss.ffff");

            DateTime time = DateTime.Now;
            string Dates = time.ToString("yyyy-MM");
            long Unix = time.ToUnix();
            string Key = "lcse&lexue";
            string md5Data = (Dates + Unix + Key).ToMd5Encryption();


            Console.WriteLine("month:" + Dates);
            Console.WriteLine("timestamp:" + Unix);
            Console.WriteLine("key:" + Key);
            Console.WriteLine("signature:" + md5Data);

            string json = "{\"month\":\"" + Dates + "\",\"timestamp\":\"" + Unix + "\",\"signature\":\"" + md5Data + "\"}";
            string EndTime = DateTime.Now.ToString("HH:mm:ss.ffff");

            Console.WriteLine("构建参数开始时间:" + StartTime + "\r\n" + "构建参数结束时间:" + EndTime);

            //string json = "?month=" + Dates + "&timestamp=" + Unix + "&signature=" + md5Data;
            string res = WebApiUtil.HttpPost("http://lexue.lenovo.com.cn/api/help/n5", json);

            Console.WriteLine("请求接口完成时间:" + DateTime.Now.ToString("HH:mm:ss.ffff"));

            Console.WriteLine(res);
            Console.ReadKey();
        }

    }
    public class RequestData
    {
        public string month { get; set; }

        public long timestamp { get; set; }

        public string signature { get; set; }

        public string Key { get { return "lcse&lexue"; } }
    }

}
